package com.ddtj.demo1.controller;

import com.ddtj.demo1.entity.Book;
import com.ddtj.demo1.service.IBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/book")
public class Controller {
    @Autowired
    IBookService bookService;
    @PostMapping("/findAll")
    public List<Book> findAll(@RequestBody(required = false) Book book){
        List<Book> all = bookService.findAll(book);
        return all;
    }
    @PostMapping("/save")
    public void save(Book book){
        bookService.save(book);
    }
    @PutMapping("/update")
    public void update(Book book){

        bookService.update(book);
    }
    @DeleteMapping("/delete")
    public void delete(Book book){
        bookService.delete(book);
    }
}
